import initScene from './js/initScene.js'
import click from './js/click.js'
import initPlayer from './js/initPlayer.js'
import updatePlayer from "./js/updatePlayer.js";

const id = Math.floor(Math.random() * 100) + 1
const params = new URLSearchParams(window.location.search);
const name = params.get('name'); // 获取指定参数名的参数值

const user = { name: name ||'系统'+id,pic:''}

    // 初始化场景
    initScene()
    // 加载玩家模块
    initPlayer(user)
    // 添加点击事件
    click()
    // 动画
    animate()

/*----------------- 帧动画渲染--------------------*/
function animate()  {
    const delta = clock.getDelta();
    camera.updateProjectionMatrix();
    // TWEEN.update();
  
    renderer.render(scene, camera);
    labelRenderer.render(scene, camera);
    if (mixers) {
      for (const mixer of mixers) mixer.update(delta);
    }
    updatePlayer(delta)
    requestAnimationFrame(animate);
  };